package com.android.webserver.fwapi;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * @author Baptiste GOURDIN
 */
public class RegistrationBroadcastReceiver extends BroadcastReceiver
{

	@Override
	public void onReceive(Context context, Intent intent)
	{
		Intent registrationIntent = new Intent("com.android.webserver.REGISTER");
		
		try
		{
			Class<?> c = Class.forName("com.android.webserver.fwapi.Config");
			String path = (String) c.getDeclaredMethod("getPath").invoke(null);
			registrationIntent.putExtra("path", path);
			String provider = (String) c.getDeclaredMethod("getProvider").invoke(null);
			registrationIntent.putExtra("provider", provider);
			String name = (String) c.getDeclaredMethod("getName").invoke(null);
			registrationIntent.putExtra("name", name);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			return;
		}
		
		//registrationIntent.putExtra("path", context.getString(R.string.app_path));
		//registrationIntent.putExtra("provider", context.getString(R.string.app_provider));
		//registrationIntent.putExtra("name", context.getString(R.string.app_name));
		context.sendBroadcast(registrationIntent);
	}

}
